<?php
/**
* get all news
*/

include_once('../../Model/Message.php');
include_once('../../DB/DBHelper.php');

$page = isset($_GET['page']) ? (is_numeric($_GET[page])?$_GET['page'] : 1 ): 1;

$helper = DBHelper::getInstance();

$page = ($page - 1) * PAGE_SIZE;

$sql = "select * from `t_news` limit  {$page} , ".PAGE_SIZE;
$result = $helper -> getRows($sql);
//var_dump($result);
?>
<html>
<head>
<link rel="stylesheet" href="./Static/css/school_main.css" />
<link rel="stylesheet" href="./Static/css/table.css" />
</head>
<body>
<table class="bordered" >
	<tr>
		<th align="center" width="200">TITLE</th>
		<th align="center"  width="400">CONTENT</th>
		<th align="center" width="60">FROM</th>
		<th align="center" width="50"> UPLOADER</th>
		<th align="center" width="200">TIME</th>
		<th align="center" width="50">USEFUL</th>
		<th align="center" width="100">Operate</th>
	</tr>
	<?php
	if($result){
		foreach ($result as $key => $value) {
	?>
	<tr>
		<td><?php echo $value['title']?></td>
		<td><?php echo $value['content']?></td>
		<td align="center"><?php echo $value['from']?></td>
		<td align="center"><?php echo $value['uploader']?></td>
		<td align="center"><?php echo $value['time']?></td>
		<td align="right"><?php echo $value['useful_co']?></td>
		<td  align="center" class="news_operation_delete" ><a href="">Delete</a></td>
	</tr>
	<?php }}?>
</table>
</body>
</html>

